package com.xiyi_design.printer_manage.service.impl;


import com.xiyi_design.printer_manage.dao.master.PrinterProductWrite;
import com.xiyi_design.printer_manage.dao.slave.PrinterProductRead;
import com.xiyi_design.printer_manage.entity.PrinterProduct;
import com.xiyi_design.printer_manage.pub.Result;
import com.xiyi_design.printer_manage.service.PrinterProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * @Auther: blackcat
 * @Date: 2023-03-05
 * @Description: com.xiyi_design.user_manage.service.impl
 * @version:
 */
@Service
public class PrinterProductServiceImpl extends BaseServiceImpl<PrinterProduct> implements PrinterProductService {
    @Autowired
    private PrinterProductWrite printerProductWrite;
    @Autowired
    private PrinterProductRead printerProductRead;
    
    @Override
    protected Mapper<PrinterProduct> getReadMapper() {
        return this.printerProductRead;
    }
    
    @Override
    protected Mapper<PrinterProduct> getWriteMapper() {
        return this.printerProductWrite;
    }
    
    @Override
    public Result getPrinterProductList(String printerId) {
        List<PrinterProduct> list = null;
        PrinterProduct pp = new PrinterProduct();
        pp.setUserId(printerId);
        try{
            list = printerProductRead.select(pp);
            if (list != null && list.size() > 0) {
                Result rs = new Result(1, "印刷商产品信息");
                rs.setCon(list);
                return rs;
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return Result.fail(0, "查询失败");
    }
}
